package com.sino.operation.util;

import java.util.List;

/**
 * @Title: PaginateUtil
 * @Description: 手动分页工具
 * @Author dengls
 * @date 2021/10/27 16:32
 */
public class PaginateUtil {

    public static List execute(List data, Integer pageIndex, Integer pageSize, int count) {
        int startCount = 0;
        int endCount = 0;
        if (pageIndex != null && pageSize != null && pageIndex > 0 && pageSize > 0) {
            startCount = pageSize * (pageIndex - 1);
            endCount = pageSize * pageIndex;
        }
        if (endCount > count) {
            endCount = count;
        }
        return data.subList(startCount, endCount);
    }
}
